import numpy
from machine import *
import nnmf
import stats
import characteristics
import blender
import trivial
import filters
import random
import quiz_test

print "creating machines"
stat_data = characteristics.stat_data
ns = nnmf.NNMF_Solver(tr, nnmf.STORE + '20f.npz', 20)
ns.read_mats()
ns.clip_low = 1.75
ns.clip_high = 4.775
ns.add_filter(filters.Movie_StdDev_Filter(tr, stat_data.basic_movie, 1.8))
characteristics = characteristics.characteristics

machines = [ns,
            trivial.User_Avg(stat_data),
            trivial.Movie_Avg(stat_data),
            trivial.MovieUser_Avg(stat_data),
           ]
"""
for machine in machines:
  print "%s: \n " % machine.name,
  machine.calc_rmse()
"""
blend = blender.Blender(blender.STORE, characteristics, machines)
blend.read_data()
blend.find_linear_weights(pr)
#blend.method = blender.LINEAR
print "calculating final rmse"
blend.calc_rmse()
blend.calc_rmse(outset=quiz_test.QuizTest(flag=quiz_test.TEST))
